package controller

import (
	"context"
	"fmt"

	v1 "mygf2/api/v1"
	"mygf2/internal/service"

	"github.com/gogf/gf/v2/frame/g"
)

var (
	Hello = cHello{}
)

type cHello struct{}

func (c *cHello) Hello(ctx context.Context, req *v1.HelloReq) (res *v1.HelloRes, err error) {
	list, _ := g.DB("video").Model("video").WhereIn("video_time", g.Array{0, 1}).All()
	html := ""
	for _, item := range list {
		url := service.GatherUrls().GetPrivateUrl(ctx, item["video_url"].String())
		fmt.Println(url)
		html = html + `<a href="` + url + `" target="_blank">` + item["id"].String() + `</a><br/>`
	}
	g.RequestFromCtx(ctx).Response.Writeln(html)

	return
}
